package com.project.config;

import com.project.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
            registry.addResourceHandler(("/stuFace/**"))
                    .addResourceLocations("file:D:\\java\\JAVA-Two\\chapter5\\JavaWeb\\stageFirst\\stuFaceImg/");
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor()) //注册拦截器
                .addPathPatterns("/main/main.html")
                .addPathPatterns("/class/class.html")
                .addPathPatterns("/room/room.html")
                .addPathPatterns("/student/student.html")
                .addPathPatterns("/user/user.html");//定义拦截范围

    }
}
